<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <title>Title</title>
    <base href="<%=request.getContextPath()%>/">
    <link rel="stylesheet" href="static/layui/css/layui.css">
    <script src="static/jquery/jquery.js"></script>
    <script src="static/layui/layui.js"></script>
    <style>
        .layui-table-cell {
            height: auto;
        }
    </style>
</head>
<body>
<div class="layui-btn-container" style="display: flex; justify-content: center; align-items: center; height: 100vh;">
    <button type="button" class="layui-btn" id="btn1">待取件</button>
    <button type="button" class="layui-btn" id="btn2">待入库</button>
    <button type="button" class="layui-btn" id="btn3">运输中</button>
    <button type="button" class="layui-btn" id="btn4">配送中</button>
    <button type="button" class="layui-btn" id="btn5">已送达</button>
</div>
</body>
<script>
    var form;

    $('#btn1').on('click', function () {
        $.ajax({
            url: 'admin/order/changestatus?status=1',
            method: "get",
            dataType: "json",
            success(res) {
                if (res.code === 200) {
                    layer.msg('操作成功！', {icon: 1}, function () {
                        /*获取当前窗口的标记值*/
                        const index = parent.layer.getFrameIndex(window.name);
                        /*关闭窗口*/
                        parent.layer.close(index);
                        /*刷新list中的表格*/
                        parent.table.reloadData('dataTable')
                    });
                } else {
                    layer.alert(res.msg, {icon: 2});
                }
            },
            error(e) {
                layer.alert('异常！')
                console.log(e);
            }
        })
    });
    $('#btn2').on('click', function () {
        $.ajax({
            url: 'admin/order/changestatus?status=2',
            method: "get",
            dataType: "json",
            success(res) {
                if (res.code === 200) {
                    layer.msg('操作成功！', {icon: 1}, function () {
                        /*获取当前窗口的标记值*/
                        const index = parent.layer.getFrameIndex(window.name);
                        /*关闭窗口*/
                        parent.layer.close(index);
                        /*刷新list中的表格*/
                        parent.table.reloadData('dataTable')
                    });
                } else {
                    layer.alert(res.msg, {icon: 2});
                }
            },
            error(e) {
                layer.alert('异常！')
                console.log(e);
            }
        })
    });
    $('#btn3').on('click', function () {
        $.ajax({
            url: 'admin/order/changestatus?status=3',
            method: "get",
            dataType: "json",
            success(res) {
                if (res.code === 200) {
                    layer.msg('操作成功！', {icon: 1}, function () {
                        /*获取当前窗口的标记值*/
                        const index = parent.layer.getFrameIndex(window.name);
                        /*关闭窗口*/
                        parent.layer.close(index);
                        /*刷新list中的表格*/
                        parent.table.reloadData('dataTable')
                    });
                } else {
                    layer.alert(res.msg, {icon: 2});
                }
            },
            error(e) {
                layer.alert('异常！')
                console.log(e);
            }
        })
    });
    $('#btn4').on('click', function () {
        $.ajax({
            url: 'admin/order/changestatus?status=4',
            method: "get",
            dataType: "json",
            success(res) {
                if (res.code === 200) {
                    layer.msg('操作成功！', {icon: 1}, function () {
                        /*获取当前窗口的标记值*/
                        const index = parent.layer.getFrameIndex(window.name);
                        /*关闭窗口*/
                        parent.layer.close(index);
                        /*刷新list中的表格*/
                        parent.table.reloadData('dataTable')
                    });
                } else {
                    layer.alert(res.msg, {icon: 2});
                }
            },
            error(e) {
                layer.alert('异常！')
                console.log(e);
            }
        })
    });
    $('#btn5').on('click', function () {
        $.ajax({
            url: 'admin/order/changestatus?status=5',
            method: "get",
            dataType: "json",
            success(res) {
                if (res.code === 200) {
                    layer.msg('操作成功！', {icon: 1}, function () {
                        /*获取当前窗口的标记值*/
                        const index = parent.layer.getFrameIndex(window.name);
                        /*关闭窗口*/
                        parent.layer.close(index);
                        /*刷新list中的表格*/
                        parent.table.reloadData('dataTable')
                    });
                } else {
                    layer.alert(res.msg, {icon: 2});
                }
            },
            error(e) {
                layer.alert('异常！')
                console.log(e);
            }
        })
    });

</script>
</html>
